package com.whmskj.xjlhsc.view.controller;

import com.whmskj.xjlhsc.controller.vo.Result;
import com.whmskj.xjlhsc.entity.Sb02EquipmentCounterAccount;
import com.whmskj.xjlhsc.service.Sb02EquipmentCounterAccountService;
import com.whmskj.xjlhsc.view.entity.vo.DBJYiledVo;
import com.whmskj.xjlhsc.view.service.DeviceRealTimeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 张
 * @version 1.0
 */

@RestController
@Tag(description = "机器实时监控",name = "机器实时监控")
@RequestMapping("/api/view/realTime")
@Slf4j
public class DeviceRealTimeController {

    @Autowired
    private DeviceRealTimeService deviceRealTimeService;
    @Autowired
    private Sb02EquipmentCounterAccountService sb02EquipmentCounterAccountService;
    @GetMapping("realTimeMonitor")
    @Operation(description = "实时监控")
    public Result realTimeMonitor(@RequestParam Integer mesId) {
        Map<String, Object> map = sb02EquipmentCounterAccountService.realTimeMonitor(mesId);
        return Result.success(map);
    }
    @GetMapping("getDBJYield")
    @Operation(description = "获取打包机产量")
    public Result getDBJYield(@RequestParam Integer mesId){
        List<DBJYiledVo>  list = deviceRealTimeService.getDBJYield(mesId);
        return Result.success(list);
    }

    @GetMapping("getYQJYield")
    @Operation(description = "获取异纤机数据")
    public Result getYQJYield(@RequestParam Integer mesId){
        List<LinkedHashMap<String, Object>>  list = deviceRealTimeService.getYQJYield(mesId);
        return Result.success(list);
    }

    @GetMapping("workShopSuspension")
    @Operation(description = "车间悬浮数据")
    public Result workShopSuspension(@RequestParam Integer workShop){
        Map<String,Object> map = deviceRealTimeService.workShopSuspension(workShop);
        return Result.success(map);
    }

    @GetMapping("/recentlyEnergy")
    @Operation(description = "最近7天电耗曲线")
    public Result recentlyEnergy(@RequestParam Integer deviceId){
       List<Map<String,Object>> list = deviceRealTimeService.recentlyEnergy(deviceId);
       return Result.success(list);
    }

    @GetMapping("/maintenance")
    @Operation(description = "设备保养")
    public Result maintenance(@RequestParam Integer deviceId){
      Map<String,Object> map = deviceRealTimeService.maintenance(deviceId);
      return Result.success(map);
    }

    @GetMapping("getDeviceInfo")
    @Operation(description = "获取机器信息")
    public Result getDeviceInfo(@RequestParam Integer deviceId){
      Sb02EquipmentCounterAccount deviceInfo = deviceRealTimeService.getDeviceInfo(deviceId);
      return Result.success(deviceInfo);
    }

}
